<template>
  <div>
    <p class="red">radio</p>
    <!--有简单的背景动画：-->
    <label class="bui-radios-label bui-radios-anim">
      <input type="radio" name="sex"/><i class="bui-radios"></i> 男
    </label>
    <label class="bui-radios-label bui-radios-anim">
      <input type="radio" checked="" name="sex"/><i class="bui-radios"></i> 女
    </label>
    <br>
    <!--无动画：-->
    <label class="bui-radios-label">
      <input type="radio" name="sex"/><i class="bui-radios"></i> 男
    </label>
    <label class="bui-radios-label">
      <input type="radio" name="sex"/><i class="bui-radios"></i> 女
    </label>
    <br>
    <!--禁用状态（disabled）：-->
    <label class="bui-radios-label">
      <input type="radio" disabled="" name="sex"/><i class="bui-radios"></i> 不男不女
    </label>
    <label class="bui-radios-label">
      <input type="radio" checked="" disabled="" name="ddd"/><i class="bui-radios"></i> 不男不女
    </label>
    <br>

    <p class="red">checkbox</p>

    <!--有简单的背景动画：-->
    <label class="bui-checkbox-label  bui-checkbox-anim">
      <input type="checkbox" checked="" name="sex"/><i class="bui-checkbox"></i> 男
    </label>
    <label class="bui-checkbox-label  bui-checkbox-anim">
      <input type="checkbox" name="sex"/><i class="bui-checkbox"></i> 女
    </label>
    <br>
    <!--无动画：-->
    <label class="bui-checkbox-label">
      <input type="checkbox" checked="" name="sex"/><i class="bui-checkbox"></i> 男
    </label>
    <label class="bui-checkbox-label">
      <input type="checkbox" name="sex"/><i class="bui-checkbox"></i> 女
    </label>
    <!--禁用状态（disabled）：-->
    <label class="bui-checkbox-label">
      <input type="checkbox" disabled="" name="sex"/><i class="bui-checkbox"></i> 不男不女
    </label>
    <label class="bui-checkbox-label">
      <input type="checkbox" checked="" disabled="" name="ddd"/><i class="bui-checkbox"></i> 不男不女
    </label>
    <br>

    <p>switch</p>
    <!--简单的过渡动画：-->
    <label class="bui-switch-label bui-switch-anim">
      <input type="checkbox" name="s"/><i class="bui-switch"></i>
    </label>
    <label class="bui-switch-label bui-switch-anim">
      <input type="checkbox" checked="" name="s"/><i class="bui-switch"></i>
    </label>
    <br>
    <!--简单的背景动画：-->
    <label class="bui-switch-label bui-switch-animbg">
      <input type="checkbox" name="s"/><i class="bui-switch"></i>
    </label>
    <label class="bui-switch-label bui-switch-animbg">
      <input type="checkbox" checked="" name="s"/><i class="bui-switch"></i>
    </label>
    <br>
    <!--无动画：-->
    <label class="bui-switch-label ">
      <input type="checkbox" name="s"/><i class="bui-switch"></i>
    </label>
    <label class="bui-switch-label ">
      <input type="checkbox" checked="" name="s"/><i class="bui-switch"></i>
    </label>
    <br>
    <!--禁用状态（disabled）：-->
    <label class="bui-switch-label">
      <input type="checkbox" disabled="" name="sex"/><i class="bui-switch"></i> 不男不女
    </label>
    <label class="bui-switch-label">
      <input type="checkbox" checked="" disabled="" name="ddd"/><i class="bui-switch"></i> 不男不女
    </label>
  </div>
</template>
<script>
export default {
  name: "",
  data: () => ({

  })
}
</script>
<style lang="scss" scoped>
  .red {
    color: #ff0033;
  }
  label.bui-radios-label {
    input {
      position: absolute;
      opacity: 0;
      visibility: hidden;
    }
    .bui-radios {
      display: inline-block;
      position: relative;
      width: 13px;
      height: 13px;
      background: #FFFFFF;
      border: 1px solid #979797;
      border-radius: 50%;
      vertical-align: -2px;
    }
    input:checked + .bui-radios:after {
      position: absolute;
      content: "";
      width: 7px;
      height: 7px;
      background-color: #FFFFFF;
      border-radius: 50%;
      top: 3px;
      left: 3px;
    }
    input:checked + .bui-radios {
      background: #00B066;
      border: 1px solid #00B066;
    }
    input:disabled + .bui-radios {
      background-color: #e8e8e8;
      border: 1px solid #979797;
    }
    input:disabled + .bui-radios:after {
      background-color: #c1c1c1;
    }
    &.bui-radios-anim .bui-radios {
      transition: background-color ease-out .3s;
    }
  }

  label.bui-checkbox-label {
    input {
      position: absolute;
      opacity: 0;
      visibility: hidden;
    }
    .bui-checkbox {
      display: inline-block;
      position: relative;
      width: 13px;
      height: 13px;
      background: #FFFFFF;
      border: 1px solid #979797;
      border-radius: 2px;
      vertical-align: -2px;
    }
    input:checked + .bui-checkbox:after {
      color: #FFFFFF;
      font-family: iconfont;
      content: "\e6c1";
      width: 13px;
      height: 13px;
      font-size: 13px;
      line-height: 13px;
      position: absolute;
      top: 1px;
      left: -1px;
    }
    input:checked + .bui-checkbox {
      background: #00B066;
      border: 1px solid #00B066;
    }
    input:disabled + .bui-checkbox {
      background-color: #e8e8e8;
      border: 1px solid #979797;
    }
    input:disabled:checked + .bui-checkbox:after {
      color: #c1c1c1;
    }
    &.bui-checkbox-anim .bui-checkbox {
      transition: background-color ease-out .3s;
    }
  }

  @mixin borderRadius($radius: 20px) {
    border-radius: $radius;
    border-top-left-radius: $radius;
    border-top-right-radius: $radius;
    border-bottom-left-radius: $radius;
    border-bottom-right-radius: $radius;
  }
  $duration: .4s;
  $checkedColor: #64bd63;
  label.bui-switch-label {
    input {
      position: absolute;
      opacity: 0;
      visibility: hidden;
    }
    input:checked {
      border-color: $checkedColor;
      box-shadow: $checkedColor 0 0 0 16px inset;
      background-color: $checkedColor;
      &:before {
        left: 27px;
      }
    }
    input:disabled + .bui-switch {
      background-color: #e8e8e8;
      border: 1px solid #dfdfdf;
      &:before {
        background-color: #c1c1c1;
      }
    }
    input:disabled:checked + .bui-switch {
      background-color: #e8e8e8;
      box-shadow: #e8e8e8 0 0 0 16px inset;
      border: 1px solid #dfdfdf;
      &:before {
        background-color: #c1c1c1;
      }
    }
    .bui-switch {
      width: 50px;
      height: 25px;
      position: relative;
      border: 1px solid #dfdfdf;
      background-color: #dfdfdf;
      box-shadow: #dfdfdf 0 0 0 inset;
      @include borderRadius();
      background-clip: content-box;
      display: inline-block;
      user-select: none;
      outline: none;
      &:before {
        content: '';
        width: 23px;
        height: 23px;
        position: absolute;
        top: 1px;
        left: 1px;
        @include borderRadius();
        background-color: #FFFFFF;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
      }
    }
    input:checked + .bui-switch {
      border-color: $checkedColor;
      box-shadow: $checkedColor 0 0 0 16px inset;
      background-color: $checkedColor;
      &:before {
        left: 27px;
      }
    }
    &.bui-switch-anim {
      transition: border cubic-bezier(0, 0, 0, 1) $duration, box-shadow cubic-bezier(0, 0, 0, 1) $duration;
      .bui-switch:before {
        transition: left 0.3s;
      }
      input:checked + .bui-switch {
        box-shadow: $checkedColor 0 0 0 16px inset;
        background-color: $checkedColor;
        transition: border ease $duration, box-shadow ease $duration, background-color ease $duration*3;
        &:before {
          transition: left 0.3s;
        }
      }
    }
    &.bui-switch-animbg {
      transition: background-color ease $duration;
      .bui-switch:before {
        transition: left 0.3s;
      }
      input:checked + .bui-switch {
        box-shadow: #dfdfdf 0 0 0 0 inset;
        background-color: $checkedColor;
        transition: border-color $duration, background-color ease $duration;
        &:before {
          transition: left .3s;
        }
      }
    }
  }
</style>
